package com.jjb.www.ui.adapter;

import android.content.Context;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.core.content.ContextCompat;

import com.hjq.shape.view.ShapeTextView;
import com.jjb.www.R;
import com.jjb.www.app.AppAdapter;
import com.jjb.www.http.api.AgencyListApi;

/**
 *    author : Android CRG
 *    github : https://github.com/getActivity/AndroidProject
 *    time   : 2018/11/05
 *    desc   : 可进行拷贝的副本
 */
public final class AgencyAdapter extends AppAdapter<AgencyListApi.Bean> {

    public AgencyAdapter(Context context) {
        super(context);
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new ViewHolder();
    }

    private final class ViewHolder extends AppAdapter<?>.ViewHolder {
        private ShapeTextView mTvLabel;
        private AppCompatTextView mTvTitle;
        private ShapeTextView mTvViceTitle;
        private ShapeTextView mTvBtnText;



        private ViewHolder() {
            super(R.layout.item_agency);
            mTvLabel = findViewById(R.id.tv_label);
            mTvTitle = findViewById(R.id.tv_title);
            mTvViceTitle = findViewById(R.id.tv_viceTitle);
            mTvBtnText = findViewById(R.id.tv_btnText);
        }

        @Override
        public void onBindView(int position) {
            mTvLabel.setText(getItem(position).getLabel());
            mTvTitle.setText(getItem(position).getTitle());
            mTvViceTitle.setText(getItem(position).getViceTitle());
            mTvBtnText.setText(getItem(position).getBtnText());
            if (getItem(position).getType()==2){
                //继教
                mTvLabel.getShapeDrawableBuilder()
                        .setSolidColor(ContextCompat.getColor(getContext(), R.color.color_3675FE))
                        .intoBackground();
            }else if (getItem(position).getType()==3){
                //岗前
                mTvLabel.getShapeDrawableBuilder()
                        .setSolidColor(ContextCompat.getColor(getContext(), R.color.color_FF8018))
                        .intoBackground();
            }
        }
    }
}